home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
020a
/
anifra.zip
/
ANIFRA.C
next >
Wrap
C/C++ Source or Header
|
1991-10-09
|
7KB
|
269 lines
/****************************************************************************/
/* anifra.c, a program for generating parameter and batch files for use with*/
/* FRACTINT. Written by Erkki Sondergaard [CI$ 100016,1620]. On YCCMR known */
/* as Erkki Soendergaard. This program is hereby placed in public domain. */
/****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
char center_opt, param_opt;
char sound[4], video[5], gif87a[4], overwrite[4], passes[2], floatopt[4];
char type[12], inside[8], outside[8], map[12], prefix[6];
float param_x, param_y, param_end_x, param_end_y, param_radius;
float center_x, center_y, center_end_x, center_end_y, center_radius;
float start_mag, current_mag, zoom_mult, offset_x, offset_y;
float step_param_x, step_param_y, step_center_x, step_center_y, step_circle;
float current_param_x, current_param_y, current_center_x, current_center_y;
int step, steps, intervals, current_interval, maxiter, bailout;
FILE *parfile, *batfile;
char parext[] = ".par";
char batext[] = ".bat";
char parname[11] = "";
char batname[11] = "";
main()
{
get_moveopt();
get_paropt();
get_batopt();
init_calc();
init_files();
for(step = 0;step < steps;step++)
{
calc_param();
calc_center();
write_par();
write_bat();
}
fclose(batfile);
fclose(parfile);
credits();
}
get_moveopt()
{
printf("\nMovement options works as follows:\n");
printf("Zoom keeps same center and applies the zoom factor to each frame.\n");
printf("Zoom only applies on center-mag.\n");
printf("Circle generates points on a circle and uses center and radius.\n");
printf("Circle starts on the top.\n");
printf("Line uses a straight line between 2 points/parameters.\n");
printf("Point keeps same point/parameter in all frames.\n");
printf("\nEnter center movement option (z/c/l/p):");
fflush(stdin);
scanf("%c",¢er_opt);
fflush(stdin);
printf("\nCenter/starting point X,Y ");
scanf("%f,%f",¢er_x,¢er_y);
if (center_opt == 'z' || center_opt == 'Z') {
printf("\nEnter start magnification:");
scanf("%f",&start_mag);
printf("\nEnter zoom multiplication factor:");
scanf("%f",&zoom_mult);
}
else {
start_mag = 0.6666667;
zoom_mult = 1.0;
}
if (center_opt == 'c' || center_opt == 'C') {
printf("\nEnter radius for center-circle:");
scanf("%f",¢er_radius);
}
else {
center_radius = 0.0;
}
if (center_opt == 'l' || center_opt == 'L') {
printf("\nEnter center end point X,Y");
scanf("%f,%f",¢er_end_x,¢er_end_y);
}
else {
center_end_x = center_x;
center_end_y = center_y;
}
printf("\nEnter parameter movement option (c/l/p):");
fflush(stdin);
scanf("%c",¶m_opt);
fflush(stdin);
printf("\nEnter center/starting parameter point X,Y ");
scanf("%f,%f",¶m_x,¶m_y);
if (param_opt == 'c' || param_opt == 'C') {
printf("\nEnter radius for parameter circle:");
scanf("%f",¶m_radius);
}
else {
param_radius = 0.0;
}
if (param_opt == 'l' || param_opt == 'L') {
printf("\nEnter parameter end point X,Y ");
scanf("%f,%f",¶m_end_x,¶m_end_y);
}
else {
param_end_x = center_x;
param_end_y = center_y;
}
printf("\nEnter number of steps:");
scanf("%d",&steps);
}
get_batopt()
{
printf("\nBatch options. Will be included in the batch file. \n");
printf("\nEnter name prefix for files and names (max. 5 char):");
scanf("%s",&prefix);
printf("\nSound=");
scanf("%s",&sound);
printf("\nVideo=");
scanf("%s",&video);
printf("\nGif87a=");
scanf("%s",&gif87a);
printf("\nOverwrite=");
scanf("%s",&overwrite);
}
get_paropt()
{
printf("\nCalculation options for the parameter file.");
printf("\n(see X menu in fractint for expected values)\n");
printf("\nPasses=");
scanf("%s",&passes);
printf("\nFloat=");
scanf("%s",&floatopt);
printf("\nType=");
scanf("%s",&type);
printf("\nMaxiter=");
scanf("%d",&maxiter);
printf("\nBailout=");
scanf("%d",&bailout);
printf("\nInside=");
scanf("%s",&inside);
printf("\nOutside=");
scanf("%s",&outside);
printf("\nMap=");
scanf("%s",&map);
}
init_files()
{
strcat(parname,prefix);
strcat(parname,parext);
if((parfile = fopen(parname,"wt"))==NULL) {
printf("\nUnable to open %s file",parname);
exit(10);
}
strcat(batname,prefix);
strcat(batname,batext);
if((batfile = fopen(batname,"wt"))==NULL) {
printf("\nUnable to open %s file",batname);
exit(10);
}
fprintf(batfile,"@rem batch file created by anifra\n");
fprintf(parfile,"/*parameter file created by anifra*/\n");
}
write_par()
{
fprintf(parfile,"%s%03d {;%s no.%03d\n",prefix,step,type, step);
fprintf(parfile," reset type=%s params=%f/%f\n",
type,current_param_x,current_param_y);
fprintf(parfile," center-mag=%f/%f/%f\n",
current_center_x,current_center_y,current_mag);
fprintf(parfile," maxiter=%d bailout=%d passes=%s\n",
maxiter,bailout,passes);
fprintf(parfile," inside=%s outside=%s map=%s }\n",
inside,outside,map);
}
write_bat()
{
fprintf(batfile,"fractint @%s.par/%s%03d batch=y savename=%s%03d ",
prefix,prefix,step,prefix,step);
fprintf(batfile,"gif87a=%s video=%s overwrite=%s sound=%s\n",
gif87a,video,overwrite,sound);
}
init_calc()
{
intervals = steps - 1;
step_param_x = (param_end_x - param_x) / intervals;
step_param_y = (param_end_y - param_y) / intervals;
step_center_x = (center_end_x - center_x) / intervals;
step_center_y = (center_end_y - center_y) / intervals;
step_circle = (2.0 * 3.1415625) / steps;
if (center_opt == 'z' || center_opt == 'Z') {
current_mag = start_mag / zoom_mult;
}
else
{
current_mag = start_mag;
}
current_param_x = param_x;
current_param_y = param_y;
current_center_x = center_x;
current_center_y = center_y;
}
calc_param()
{
if (param_opt == 'l' || param_opt == 'L') {
current_param_x = param_x + (step_param_x * step);
current_param_y = param_y + (step_param_y * step);
}
if (param_opt == 'c' || param_opt == 'C') {
offset_x=(sin( (step_circle * step)));
offset_y=(cos( (step_circle * step)));
current_param_x = param_x + (param_radius * offset_x);
current_param_y = param_y + (param_radius * offset_y);
}
}
calc_center()
{
if (center_opt == 'z' || center_opt == 'Z') {
current_mag = current_mag * zoom_mult;
}
if (center_opt == 'l' || center_opt == 'L') {
current_center_x = center_x + (step_center_x * step);
current_center_y = center_y + (step_center_y * step);
}
if (center_opt == 'c' || center_opt == 'C') {
offset_x=(sin( (step_circle * step)));
offset_y=(cos( (step_circle * step)));
current_center_x = center_x + (center_radius * offset_x);
current_center_y = center_y + (center_radius * offset_y);
}
}
credits()
{
printf("\n\n\n\nAnifra ver. 1.0 written by:\n\n");
printf("\nErkki Soendergaard");
printf("\n ");
printf("\nAarhusgade 44, 1 tv. ");
printf("\nDK-2100 Copenhagen Oe. ");
printf("\nDenmark ");
printf("\nEurope ");
printf("\n\nCIS [100016,1620]\n");
}